<?php
    use User\Model\LiveModel;
?>
<style>
    .table>thead>tr>th{width:25%}
</style>
<div id="page-wrapper">
    <div class="row">
        <div class="col-lg-12">
            <h1 class="page-header">直播分类</h1>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <a href="/User/Live/editCategory" class="btn btn-success">新增分类</a>
                </div>
                <div class="panel-body">
                    <div class="col-lg-12">
                        <div class="table-responsive">
                            <table class="table">
                                <thead>
                                <tr>
                                    <th>序号</th>
                                    <th>分类名</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <volist name="list" id="item">
                                    <tr>
                                        <td>{$item.displayorder}</td>
                                        <td>{$item.name}</td>
                                        <td>
                                            <if condition="$item.status eq LiveModel::CATEGORY_ACTIVE">
                                                <span class="label label-success">正常</span>
                                            <else/>
                                                <span class="label label-warning">禁用</span>
                                            </if>
                                        </td>
                                        <td>
                                            <a href="/User/Live/editCategory?id={$item['id']}" title="编辑" class="btn btn-default"><i class="fa fa-edit"></i></a>
                                            <a href="javascript:;" title="删除" onclick="return deleteItem({$item['id']});" class="btn btn-default"><i class="fa fa-times"></i></a>
                                        </td>
                                    </tr>
                                </volist>
                                </tbody>
                            </table>
                        </div>
                        <div class="pages">
                            {$page}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    function deleteItem(id){
        if(!confirm('确认删除吗？')) return false;
        $.ajax({
            data: {id: id},
            dataType: 'json',
            url: '/User/Live/deleteCategory',
            type: 'get',
            success: function (res) {
                alert(res['info']);
                window.location.reload();
            }
        });
        return false;
    }
</script>